<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">
  
  <head>
    
    <%@ include file="/WEB-INF/include/meta.jsp"%>
    <%@ include file="/WEB-INF/include/css.jsp"%>
    <link href="${ctx.resource}/css/goals.css" rel="stylesheet">
  </head>
  <!-- end header -->
  <body>
    <div class="page-group">
      <div class="page page-current">
        
        <header class="bar bar-nav fs-header-small">
          <a href="${ctx.host}/profile/courses/${courseSchedule.courseRound.id}" class="icon icon-left pull-left"></a>
          <h1 class="title">课程${session}</h1>
        </header>
        
        <div class="content">
        
          <div class="list-block media-list no-margin">
            <ul>
              <li class="course">
                <div class="item-content">
                  <div class="item-media"><img src="${cloud.prod}/${courseSchedule.course.cover}-avatar" style='width: 4rem;'></div>
                  <div class="item-inner">
                    <div class="item-title-row">
                      <div class="item-title">${courseSchedule.course.name}</div>
                    </div>
                    <div class="item-subtitle" style="margin: .3rem 0 0 0;">门店：<span class="color-default">${courseSchedule.site.name}</span></div>
                    <div class="item-text">
                      教练：<span class="color-default">${courseSchedule.coach.name}</span><br>
                      时间：&nbsp;<span class="color-blue"><fmt:formatDate value="${courseSchedule.occurDate}" pattern="yyyy-MM-dd"/>&nbsp;&nbsp;${courseSchedule.occurHour}</span>
                    </div>
                  </div>
                </div>
              </li>
            </ul>
          </div>
          
          <c:if test="${not empty plannedSchedule}">
            <div style="background: white;padding: .25rem .75rem;margin: 1rem 0 0 0;">上课内容：
              <span class="pull-right">
                <c:forEach var="content" items="${plannedSchedule.contentList}" varStatus="status">
                  ${status.index eq 0 ? '' : '+'}${content.description}
                </c:forEach>
              </span>
            </div>
          </c:if>
          
          <c:if test="${not empty coursewares}">
            <div class="content-block course-target-course target-course" style="padding: 0; margin: 1rem 0 0 0;">
              <div class="basic-item flex-box basic-header">
                <div class="item" style="width: 30%;flex: none;">动作</div>
                <div class="item" style="width: 10%;flex: none;">组数</div>
                <div class="item" style="width: 20%;flex: none;">每组次数</div>
                <div class="item" style="width: 20%;flex: none;">最大重量</div>
                <div class="item" style="width: 10%;flex: none;">计时</div>
                <div class="item" style="width: 10%;flex: none;"></div>
              </div>
              <c:forEach var="courseware" items="${coursewares}">
                <div class="basic-item flex-box">
                  <div class="item flex-shrink" style="width: 30%;flex: none;">${courseware.movement.name}</div>
                  <div class="item" style="width: 10%;flex: none;"><span class="big-size">${courseware.groupAmount}</span></div>
                  <div class="item" style="width: 20%;flex: none;"><span class="big-size">${courseware.movementNumber}</span></div>
                  <div class="item" style="width: 20%;flex: none;"><span class="big-size">${courseware.maxWeight}</span></div>
                  <div class="item" style="width: 10%;flex: none;"><span class="big-size">${courseware.time}</span></div>
                  <a class="item" style="width: 10%;flex: none;color: #929292" href="${ctx.host}/rounds/${courseSchedule.courseRound.id}/course-coursewares/${courseSchedule.id}/coursewares/${courseware.id}"><span class="icon icon-right"></span></a>
                </div>
              </c:forEach>
            </div>
          </c:if>
          
          <c:choose>
            
            <c:when test="${courseSchedule.scheduleStatus.finish}">
              <div class="coach-comment">
                <h1>教练寄语：</h1>
                <p>${courseSchedule.comment}</p>
              </div>
            </c:when>
            <c:when test="${courseSchedule.scheduleStatus.expiry}">
              <div class="coach-comment">
                <p class="color-danger">课时已逾期</p>
              </div>
            </c:when>
            <c:when test="${courseSchedule.scheduleStatus.ready && (courseSchedule.courseRound.courseStatus.hold)}">
              <div class="coach-comment">
                <p class="color-danger">课程已冻结</p>
              </div>
            </c:when>
            <c:when test="${courseSchedule.scheduleStatus.ready and (courseSchedule.courseRound.courseStatus.expire or courseSchedule.courseRound.courseStatus.cancel or courseSchedule.courseRound.courseStatus.activate)}">
              <div class="coach-comment">
                <p class="color-danger">课程${courseSchedule.courseRound.courseStatus.description}</p>
              </div>
            </c:when>
            <c:otherwise>
              <div style="padding: 1rem 2rem; margin-top: 1rem; background-color: #FFF; text-align: center;" >
                
                <c:choose>
                  <c:when test="${courseSchedule.couldSignin()}">
                    <p class="text-center" style="margin: .5rem;">签到二维码</p>
                    <img class="qrcode hide" alt="" src="${ctx.resource}/image/qrcode-loading.gif" style="width: 80%; margin: 0 auto; text-align: center;">
                     <p id="qrcode-create"><a href="javascript:void(0);" class="button button-fill button-warning">生成二维码</a></p>
                    <p class="loading-tips" style="font-size: 12px; margin-top: 0px; color: #999;">点击上方按钮生成二维码。</p>
                  </c:when>
                  <c:when test="${courseSchedule.expiry()}">
                    <p class="color-danger">签到时间已过</p>
                  </c:when>
                  <c:otherwise>
                    <p class="color-danger">上课时间未到，暂无签到二维码</p>
                  </c:otherwise>
                </c:choose>
                
                <p class="text-center" style="font-size: 14px; color: #777;">签到时间为课程当天&nbsp;
                  <span class="text-danger">
                    ${courseSchedule.signTimeString()}
                  </span>
                </p>
                
                <c:if test="${courseSchedule.courseType.individual && courseSchedule.couldEdit()}">
                  <p><a href="${ctx.host}/profile/courses/${courseSchedule.courseRound.id}/appointment?scheduleId=${courseSchedule.id}&site=${courseSchedule.site.id}" class="button button-big button-success button-fill" style="background-color: #65C1B5; border-color: #65C1B5; color: #FFF; font-weight: bolder;">预约换课</a></p>
                </c:if>
                <c:if test="${(courseSchedule.courseType.year||courseSchedule.courseType.individual) && courseSchedule.couldCancel()}">
                  <p><a href="${ctx.host}/profile/course-schedules/${courseSchedule.id}/cancel" class="button button-big button-success button-fill" style="background-color: #65C1B5; border-color: #65C1B5; color: #FFF; font-weight: bolder;">取消预约</a></p>
                </c:if>
              </div>
            </c:otherwise>
            
          </c:choose>
          
        </div>
        <!-- End Content -->
        
      </div>
    </div>
    
    <%@ include file="/WEB-INF/include/script.jsp"%>
    <d:resource type="script" root="${ctx.resource}/build" src="js/page/course/schedule-detail.js" />
    <script type="text/javascript">
      var jsConfig = JSON.parse('${wechatJsConfig}')
      require(['page/course/schedule-detail'], function(page) {
        page.init({
          jsConfig: jsConfig,
          scheduleId: '${courseSchedule.id}'
        })
      })
    </script>
    
  </body>
</html>